// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RoleInstanceWrapper.cs" company="AzureContrib (Open source library http://azurecontrib.codeplex.com)">
//   Microsoft Public License (Ms-PL)
// </copyright>
// <summary>
//   Exception for errors when handling Windows Azure Cloud Drives.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System.Collections.Generic;

using Microsoft.WindowsAzure.ServiceRuntime;

namespace AzureContrib.WindowsAzure.ServiceRuntime
{
	internal class RoleInstanceWrapper : IRoleInstance
	{
		private readonly RoleInstance roleInstance;

		public RoleInstanceWrapper(RoleInstance roleInstance)
		{
			this.roleInstance = roleInstance;
		}

		public string Id
		{
			get { return roleInstance.Id; }
		}

		public int UpdateDomain
		{
			get
			{
				return roleInstance.UpdateDomain;
			}
		}

		public int FaultDomain
		{
			get
			{
				return roleInstance.FaultDomain;
			}
		}

		public IRole Role
		{
			get
			{
				return new RoleWrapper(roleInstance.Role);
			}
		}

		public IDictionary<string, IRoleInstanceEndpoint> InstanceEndpoints
		{
			get
			{
				var roleInstanceEndpoints = new Dictionary<string, IRoleInstanceEndpoint>();
				roleInstance.InstanceEndpoints.ForEach(keyValuePair => roleInstanceEndpoints.Add(keyValuePair.Key, new RoleInstanceEndpointWrapper(keyValuePair.Value)));
				return roleInstanceEndpoints;
			}
		}
	}
}